//
//  DSSHMeApplyForMediateVC.m
//  DSSH
//
//  Created by lcy on 16/4/5.
//  Copyright © 2016年 lcy. All rights reserved.
//

#import "DSSHMeApplyForMediateVC.h"
#import "UIView+Round.h"
#import <QuartzCore/QuartzCore.h>
@interface DSSHMeApplyForMediateVC ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView* applyMediateTableView;
@end

@implementation DSSHMeApplyForMediateVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupViewAndData];
    // Do any additional setup after loading the view.
}
-(void)setupViewAndData
{
    self.title = @"申请调处";
    self.view.backgroundColor = [UIColor whiteColor];
    self.applyMediateTableView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];
    self.applyMediateTableView.delegate = self;
    self.applyMediateTableView.dataSource = self;
    self.applyMediateTableView.tableFooterView = [[UIView alloc]init];
    [self.view addSubview:self.applyMediateTableView];
    
    UIBarButtonItem * backBarBtn = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"fanhui"] style:UIBarButtonItemStylePlain target:self action:@selector(backBarBtnClick)];
    self.navigationItem.leftBarButtonItem = backBarBtn;
}
-(void)backBarBtnClick
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 1)
    {
        return 3;
    }else
    {
        return 1;
    }
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];
    if (!cell)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellID"];
        [cell.contentView getRoundView:5];
        cell.contentView.layer.borderColor = [[UIColor groupTableViewBackgroundColor]CGColor];
        cell.contentView.layer.borderWidth = 1;
    }
    if (indexPath.section == 0)
    {
        UITextView * textView = [UITextView new];
        textView.layer.borderColor = [[UIColor groupTableViewBackgroundColor]CGColor];
        textView.layer.borderWidth = 1;
        [textView getRoundView:5];
        [cell.contentView addSubview:textView];
        textView.text = @"请填写调处说明。";
        textView.font = FONT(13);
        textView.textColor = [UIColor grayColor];
        [textView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(cell.contentView).with.offset(10*HIGHT_SCALE);
            make.right.equalTo(cell.contentView).with.offset(-5*WIDTH_SCALE);
            make.left.equalTo(cell.contentView.mas_left).with.offset(5*WIDTH_SCALE);
            make.height.mas_equalTo(100*HIGHT_SCALE);
        }];
    }
    if (indexPath.section == 1)
    {
        cell.textLabel.text = @"项目名称：未来之光";
        cell.textLabel.font = FONT(14);
        UIButton * button = [UIButton new];
        button.tag = indexPath.row;
        [button setImage:[UIImage imageNamed:@"weixuan"] forState:UIControlStateNormal];
        [button setImage:[UIImage imageNamed:@"dui"] forState:UIControlStateSelected];
        [button addTarget:self action:@selector(clickCellBtn:) forControlEvents:UIControlEventTouchUpInside];
        [cell.contentView addSubview:button];
        
        [button mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(cell.contentView.mas_centerY);
            make.right.equalTo(cell.contentView).with.offset(-10*WIDTH_SCALE);
            make.size.mas_equalTo(CGSizeMake(19*WIDTH_SCALE, 19*WIDTH_SCALE));
        }];
    }
    if (indexPath.section == 2)
    {
        UIButton * submitBtn = [UIButton new];
        [submitBtn setTitle:@"提交" forState:UIControlStateNormal];
        [submitBtn setBackgroundColor:RGBA(242, 80, 87, 1)];
        [submitBtn addTarget:self action:@selector(submitBtnClick) forControlEvents:UIControlEventTouchUpInside];
        [cell.contentView addSubview:submitBtn];
        
        [submitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(cell.contentView).with.offset(10*WIDTH_SCALE);
            make.right.equalTo(cell.contentView).with.offset(-10*WIDTH_SCALE);
            make.top.equalTo(cell.contentView).with.offset(5*HIGHT_SCALE);
            make.bottom.equalTo(cell.contentView.mas_bottom).with.offset(-5*HIGHT_SCALE);
        }];
    }
    return cell;
}

-(void)clickCellBtn:(UIButton*)btn
{
    btn.selected = YES;
}
#pragma 点击提交按钮
-(void)submitBtnClick
{
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 3*HIGHT_SCALE;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.0001*HIGHT_SCALE;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0)
    {
        return 190*HIGHT_SCALE;
    }else
    {
        return 44;
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
